package com.demo.modalframe3.listener;

import com.demo.modalframe3.Frame2;
import com.demo.modalframe3.utils.AppendTextFrame;

import javax.swing.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

public class FrameComponentListener extends ComponentAdapter {

    @Override
    public void componentShown(ComponentEvent e) {
        JFrame frame = (JFrame)e.getSource();
        if (frame instanceof AppendTextFrame) {
            ((AppendTextFrame)frame).appendText2TextPane(e.paramString());
        }
        super.componentShown(e);
    }

    @Override
    public void componentHidden(ComponentEvent e) {
        JFrame frame = (JFrame)e.getSource();
        if (frame instanceof AppendTextFrame) {
            ((AppendTextFrame)frame).appendText2TextPane(e.paramString());
        }
        super.componentHidden(e);
    }
}
